

package com.viweb.storemanager.common;

import com.l2fprod.common.swing.JButtonBar;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JToggleButton;


public class ButtonBarFactory {
    protected String baseImagePath;
    protected JButtonBar buttonBar = new JButtonBar(JButtonBar.VERTICAL);
    protected ButtonGroup group = new ButtonGroup();
    
    /** Creates a new instance of ButtonBarFactory */
    public ButtonBarFactory() {
    }
    
    public ButtonBarFactory(String baseImagePath) {
        this.setBaseImagePath(baseImagePath);
    }
    
    public JButtonBar getButtonBar() {
        return this.buttonBar;
    }
    
    public JToggleButton addButton(String title, String icon) {
        JToggleButton button = new JToggleButton(title, this.createImageIcon(icon));
        // button.setUI(new ToogleButtonSRUI());
        // System.out.print(button.getUI());
        buttonBar.add(button);
        group.add(button);
        
        return button;
    }
    
    protected ImageIcon createImageIcon(String icon) {
        return new ImageIcon(getClass().getResource(baseImagePath + icon));
    }
    
    public void setBaseImagePath(String baseImagePath) {
        this.baseImagePath = baseImagePath;
    }
    
}